<div class="container" style="margin-top: 50px">
    <form id="form_usuario" class="form-horizontal well" action="<?php echo $this->baseUrl('/admin/usuario/salvar') ?>/id/<?php echo $this->usuario['id_usuario'] ?>" method="post">
        <fieldset>
            <legend><?php echo $this->titulo; ?></legend>
            <div class="control-group">
                <label class="control-label" for="tx_nome">Nome</label>
                <div class="controls">
                    <input class="input-xlarge required" type="text" name="tx_nome" id="tx_nome" maxlength="45"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="tx_email">E-mail</label>
                <div class="controls">
                    <input class="input-xlarge email" type="text" name="tx_email" id="tx_email" maxlength="65"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="tx_login">Login</label>
                <div class="controls">
                    <input class="input-xlarge" type="text" name="tx_login" id="tx_login" value=""/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="tx_senha">Senha</label>
                <div class="controls">
                    <input class="input-xlarge" type="password" name="tx_senha" id="tx_senha" value=""/>
                </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="tx_tipo_usuario">Tipo do usuário</label>
                <div class="controls">
                    <input class="input-xlarge" readonly type="text" name="tx_tipo_usuario" id="tx_tipo_usuario" 
                           value="<?php
if (!empty($this->usuario)) :
    echo $this->usuario['tx_tipo_usuario'];
else:

    echo "Administrador";
endif;
?>"/>
                </div>
            </div>

            <div class="form-actions">
                <input class="btn btn-primary" id="btEnviar" type="submit" value="Salvar"/>
                <input class="btn" id="btVoltar" onclick="window.back()" type="button" value="Voltar"/>
            </div>
        </fieldset>
    </form>
</div>

<div id="feedbackUsu">
    <p style="color: #000 !important"></p>
</div>

<script>
    var dataForm = <?php echo Zend_Json::encode($this->usuario); ?>;
    
    $(function(){
    
        $('#form_usuario').populate(dataForm);
        
        $('#form_usuario').validate({
            submitHandler: function(form) {
                jQuery(form).ajaxSubmit({
                    dataType:  'json', 
                    success: function(r){
                        if(r.tipo == 'sucesso'){                    
                            $('#feedbackUsu p').html(r.msg);
                            $( "#feedbackUsu" ).dialog({
                                modal: true,
                                buttons: {
                                    Ok: function() {
                                        $(this).dialog("close");
                                        window.location = r.url;
                                    }
                                }
                            });
                        } else {
                            $('#feedbackUsu p').html(r.msg);
                            $('#feedbackUsu').dialog({
                                buttons: {
                                    Ok: function() {
                                        $( this ).dialog( "close" );
                                    }
                                }
                            });
                        }
                    } 
                });
            } 
        });
    });
        
</script>